<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
    <head>
    <meta charset="UTF-8">
    <title>添加配件</title>
	<script src="<%=basePath %>web/js/jquery.min.js"></script>
    <script src="<%=basePath %>web/js/jquery.easyui.min.js"></script>
    <script src="<%=basePath %>web/js/easyui-lang-zh_CN.js"></script>
    <link rel="stylesheet" href="<%=basePath %>web/themes/icon.css">
    <link rel="stylesheet" href="<%=basePath %>web/themes/default/easyui.css">
    <link rel="stylesheet" href="<%=basePath %>web/css/wu.css">
	<script>
        var  selectIndex = -1;
		var path=$("#path").val();  
        function hideTable(){
            $("#searchdiv").toggle();
        }
        $(function(){
                $("#productList").datagrid({
                url:'/kxmanage/osb2/findallpart',
                pageNumber:1,
                pageSize:5,
                pageList:[5,10],
                pagination:true,
                checkOnSelect:true,
                columns:[[
                    {field:'ck',checkbox:true},
                    {field:'code',title:'配件单号',width:140},
                    {field:'partName',title:'配件名称',width:200},
                    {field:'partTypeName',title:'配件类别',width:100},
                    {field:'partBrand',title:'配件品牌',width:70},
                    {field:'partNo',title:'配件型号',width:80},
                    {field:'sellPrice',title:'销售单价',width:100,
                       formatter:function(value,row,index){
                            return "￥"+row.sellPrice;
                       }
                    },
                    {field:'memo',title:'备注',width:230}
                ]],
                onClickRow:function(index,data){
                	$(this).datagrid('unselectRow',index);
                },
                toolbar:'#wu_toolbar'
            })
         $("#search_btn").click(function(){
	       var form=$("#form1");
  		 $("#productList").datagrid('load',serializeForm(form));
         })
         
        
       $('#partTypeId').combobox({    
          url:'/kxmanage/osb2/findpart',    
          valueField:'id',    
          textField:'typeName', 
           
       }); 
        
       })
 //添加按钮获取数据       
         function addpart(){
          var row = $('#productList').datagrid('getSelections');
			if(row!=null&&row!=''){
	          parent.addpart(row);
			}else{
				alert("请选择配件")
			}

        }
       // 退出执行       
        function closePart(){
          parent.closePart();
        }
        
        
        //将表单序列化
		function serializeForm(form){
			var obj={};
			$.each(form.serializeArray(),function(index){
				  if(obj[this['name']]){
					obj[this['name']]=obj[this['name']]+','+this['value']
				 }else{
				   obj[this['name']]=this['value'];
				 }
			});
			return obj;
		}  
	//reset_btn
   $(function(){
      $('#reset_btn').click(function(){
           $('#form1').form('clear'); 
          
            
      })  
   })	
		
     </script>
  </head>
  
  <body>
    <div id="wu_toolbar">
    <input type="hidden" id="path" value="${pageContext.request.contextPath}"/>
    <div id="searchdiv" style="display: block;width: 100%;">
        <form name="form1" id="form1"> 
            <table width="100%" border="0" cellspacing="0" style="background-color:#c9dfff;" >
                <tbody><tr>
                    <td width="100" style="font-size:15px;"><b>检索条件:</b></td>
                    <td width="100" style="font-size:13px;" align="right">配件品牌:</td>
                    <td width="130" align="left"><input name="partBrand" class="easyui-textbox" type="text" id="findName" value="" maxlength="70" style="width:120px;height:30px"></td>
                    <td width="100" style="font-size:13px;"align="right">配件型号:</td>
                    <td width="90" align="left"><input name="partNo" class="easyui-textbox" type="text" id="findCode" value="" maxlength="70" style="width:120px;height:30px"></td>
                    <td width="100" style="font-size:13px;"align="right">配件名称:</td>
                    <td width="90" align="left"><input name="partName" class="easyui-textbox" type="text" id="findpart" value="" maxlength="70" style="width:120px;height:30px"></td>
                     <td width="70" style="font-size:13px;"align="right">类别:</td>
                    <td width="100" align="left">
                    <select name="partTypeId" id="partTypeId" class="easyui-combobox"  style="width:120px;height:30px" panelHeight="150px">
                    
                    </select> 
                    </td>
                    <td width="72">
                        <a id="search_btn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'">搜索</a>
                    </td>
                    <td width="72">
                        <a id="reset_btn"  class="easyui-linkbutton" data-options="iconCls:'icon-refresh'">重置</a>
                    </td>
                    <td width="0"></td>
                </tr>
                </tbody>
            </table>
            <input type="hidden" id="menuCode" value="100001001">
        </form>
    </div>
</div>
<div id="productList" class="easyui-datagrid">

</div>
<br/>

<div id="addButton" style="float:right">
  <a href="javascript:addpart()" class="easyui-linkbutton" style="margin-right: 10px">添加配件</a>
  <a href="javascript:closePart()" class="easyui-linkbutton">退出</a>
</div>
  </body>
</html>
